#!/bin/bash

exitCode=0
for f in apib/*.h apib/*.cc test/*.h test/*.cc
do
  replacements=`clang-format --style=google --output-replacements-xml ${f} | grep '<replacement ' | wc -l`
  if [ ${replacements} -gt 0 ]
  then
    echo "${f}: ${replacements} required"
    exitCode=1
  fi
done

if [ ${exitCode} -ne 0 ]
then
  echo ""
  echo "******"
  echo "Some files need formatting."
  echo "Run clang-format -i --style=google on each"
  echo "******"
fi

exit ${exitCode}
